package com.zhang.dft_project.controller;

import com.zhang.dft_project.event.NoticeEvent;
import jakarta.annotation.Resource;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class NoticeTest {
    @Resource
    private ApplicationEventPublisher publisher;

    @GetMapping("testNotice")
    public String noticeListenerTest(String msg){
        //创建事件
        NoticeEvent e = new NoticeEvent(this, "测试事件");
        publisher.publishEvent(e);
        return "发布事件";
    };
}
